package com.kevin.hw.socket;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

/**
 * @author: kevin
 * @date: 2017/8/10
 * @description:
 */
public class UserClient {

    private Socket socket;
    public UserClient() throws IOException {

        socket = new Socket("localhost",8888);
    }

    public int getAge() throws IOException {

        ObjectOutputStream outputStream = new ObjectOutputStream(socket.getOutputStream());

        outputStream.writeObject("age");
        outputStream.flush();

        ObjectInputStream objectInputStream = new ObjectInputStream(socket.getInputStream());

        return  objectInputStream.readInt();



    }
}
